import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home/Home'

Vue.use(Router)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/city',
    name: 'City',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "City" */ '../views/City/City.vue')
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import(/* webpackChunkName: "Detail" */ '../views/Detail/Detail.vue')
  }
]


export default new Router({
  routes,
  // 重置各个页面滚动条的位置
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
